<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>受控组件</title>

</head>
<body>
<div id="test"></div>
</body>
<script src="../js/new/react.development.js"></script>
<script src="../js/new/react-dom.development.js"></script>
<!--将jsx转为js-->
<script src="../js/new/babel.min.js"></script>
<script src="../js/new/prop-types.js"></script>
<!--babel  由babel转换jsx-->
<script type="text/babel">
    class Time extends React.Component {
        state = {
            data: new Date()
        }

        componentDidMount() {
            setInterval(() => {
                this.setState({
                    data: new Date()
                })
            }, 1000)
        }

        render() {
            return (
                <div>
                    <h1>hello</h1>
                    <input type="text"/>
                    <span>
                        现在是:{this.state.data.toTimeString()}
                    </span>
                </div>
            )
        }
    }

    ReactDOM.render(<Time/>, document.getElementById('test'))
</script>
</html>